<include file="Public/mobile_head"/>
<link href="{:ADDON_PUBLIC_PATH}/main.css?v={:rand(1000,9999)}" rel="stylesheet" type="text/css">
<script type="text/javascript" src="__STATIC__/layer/layer.m.js"></script>
<script type="text/javascript" src="{:ADDON_PUBLIC_PATH}/iscroll.js"></script>
<script type="text/javascript" src="{:ADDON_PUBLIC_PATH}/main.js"></script>
<script type="text/javascript">
    var page_num = 1;
    function pullUpAction () {
        var html = '';
        setTimeout(function () {
            $.ajax({
                url:"{:U('get_more_logs')}&uid={$myinfo.id}&page_num="+(++page_num),
                dataType:"json",
                success:function(data){
                    for(var i in data.scoreLogs){
                        html +='<tr><td width="40%">'+data.scoreLogs[i].createTime+'</td> ' +
                                '<td width="10%"><img class="lingxing" src="{:ADDON_PUBLIC_PATH}/lingxing.png"/></td>' +
                                '<td>'+data.scoreLogs[i].detail+'</td></tr>';
                    }
                    $('#data_tb').html(html);
                }
            });
            myScroll.refresh();
        }, 1000);
    }

    function checkNewOrder() {
        $.ajax({
            url:"{:U('checkNewOrder')}&uid={$myinfo.id}",
            dataType:"json",
            success:function(data){
                if(data.status == 1){
                    layer.open({
                        title: ['订单付款确认','background-color:#f7812e;'],
                        content: data.detail,
                        btn: ['取消', '扣积分'],
                        shadeClose: false,
                        yes: function(){    //取消
                            handleOrder(data.oid, 0);
                        }, no: function(){  //确认
                            handleOrder(data.oid, 1);
                        }
                    });
                }
            }
        });
    }

    function handleOrder(oid, isConfirm) {
        $.ajax({
            url:"{:U('handleOrder')}&uid={$myinfo.id}&oid=" + oid + "&is_confirm=" + isConfirm,
            dataType:"json",
            success:function(data){
                if (data.status == 1) {
                    if (isConfirm == 1) {
                        layer.open({content: '确认成功', time: 1});
                        location.reload(true);
                    } else {
                        layer.open({content: '取消成功', time: 1});
                    }

                } else {
                    if (isConfirm == 1) {
                        layer.open({content: '确认失败', time: 1});
                    } else {
                        layer.open({content: '取消失败', time: 1});
                    }
                }
            }
        });
    }


    $(function () {
        checkNewOrder();
        setInterval('checkNewOrder()', 120000); //每两分钟检查一次订单
    });
</script>
<body>
<div class="container body">
    <div id="head_div">
        <div id="head_div_top">
            <span style="top: 25%; font-size: 16px;">首页</span>
            <img onclick="location.href='{:addons_url(\'Suggestions://Suggestions/suggest\')}'" src="{:ADDON_PUBLIC_PATH}/comment.png"/>
        </div>
        <div id="head_div_main">
            <img src="{$myinfo.image}" width="50px">

            <div id="user_info_div">
                <span>ID: {$myinfo.id}</span><br/>
                <span>{$myinfo.nickname}</span>
                <!--<span>积分罐：<font color="red">{$myinfo.integralTank}</font></span>-->
            </div>
            <div id="user_score_div" align="center">
                当前积分：{$myinfo.score}</div>
        </div>
    </div>
    <div id="record_div">
        <div style="position: fixed;">
            <img src="{:ADDON_PUBLIC_PATH}/score_record_line.png"/>
            <a href="{:addons_url('BLConn://Web/exchange')}">
                <div style="text-align: center; background: #dbc28a; color: white; width: 50px; padding: 1px 4px; margin: 0 auto; float: right; position: relative; top: -26px; right: 20px;">
                    进入兑换
                </div>
            </a>
        </div>
        <div style="height: 30px"></div>
        <if condition="$scoreLogs">
            <div id="wrapper">
                <div id="scroller">
                    <table id="data_tb" width="100%" border="0">
                            <foreach name="scoreLogs" item="vo" >
                                <tr>
                                    <td width="40%">{$vo.createTime|time_format}</td>
                                    <td width="10%"><img class="lingxing" src="{:ADDON_PUBLIC_PATH}/lingxing.png"/></td>
                                    <td>{$vo.detail}</td>
                                </tr>
                            </foreach>
                    </table>
                    <div id="pullUp" style="display:none;">
                        <span class="pullUpIcon"></span>
                        <span class="pullUpLabel">Pull up to refresh...</span>
                    </div>
                </div>
            </div>
        <else />
            <span style="position:relative;top: 40%;left: 40%;">暂无数据~</span>
        </if>
    </div>
    <div id="my_circle_div">
        <img src="{:ADDON_PUBLIC_PATH}/my.png"/>
        <span id="to_me">推荐我的人：</span>
        <if condition="$myReferrer">
            <div class="person_info">
                <img src="{$myReferrer.image}" width="40px" height="40px">
                <div><span>{$myReferrer.nickname}</span><br/>
                    <span>积分罐：<font color="red">{$myReferrer.integralTank}</font></span></div>
            </div>
        <else />
            <div class="person_info">
                <span style="color: #c7c6c4;">暂无信息~</span>
            </div>
        </if>
        <span id="from_me">我推荐的人：</span><span>( {$referers_amount} )</span>
        <if condition="$referers">
            <foreach name="referers" item="vo" >
                <div class="person_info">
                    <img src="{$vo.image}" width="40px" height="40px">
                    <div><span>{$vo.nickname}</span><br/>
                        <span>积分罐：<font color="red">{$vo.integralTank}</font></span></div>
                </div>
            </foreach>
        <else />
            <div class="person_info">
                <span style="color: #c7c6c4;">暂无信息~</span>
            </div>
        </if>

        <span id="register_url">注册邀请二维码：</span>
        <div>
            <img src="{$referUrl}" width="25%"/>
        </div>
    </div>
</div>
</body>
</html>
